package work01;

import java.util.Random;

public class work01shuffle2DArrayElements {
    public static void main(String[] args) {
        int[] [] arr1 = {{1,2},{3,4,5,6},{7,8,9,10,11}};
        int count = 0;
        int temp;
        int l=0;
        int TotalNum = 0;
        Random r = new Random();
        for(int i=0;i<arr1.length;i++){
            for(int j=0;j<arr1[i].length;j++){
                TotalNum++;
            }
        }
        for(int i=0;i<arr1.length;i++){
            for(int j=0;j<arr1[i].length;j++){
                count = r.nextInt(TotalNum)+1;
                while(count>arr1[l].length){
                    count-=arr1[l].length;
                    l++;
                }
                temp=arr1[l][count-1];
                arr1[l][count-1]=arr1[i][j];
                arr1[i][j]=temp;
                l=0;
            }
        }
        for(int i=0;i<arr1.length;i++){
            for(int j=0;j<arr1[i].length;j++){
                System.out.print(arr1[i][j]+"  ");
            }
            System.out.println("");
        }
    }
}
